package io.finer.erp.jeecg.bas.util;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class ArraySum {
	private static List<String> list = new ArrayList<String>();

	public static void main(String[] args) {
		int[] a = {25,26,26,26,27,27,27,27,27,28,28,28,29,30,30};
		int initVal = 108;
		for (int i = 1; i < 1 << a.length; i++) {
			int sum = 0;
			StringBuffer sb = new StringBuffer();
			for (int j = 0; j < a.length; j++) {
				if ((i & 1 << j) != 0) { 
					sum += a[j];
					sb.append(a[j]).append("+");
				}
			}
			if (sum == initVal) {
				System.out.println(sb);
				String[] str_array = sb.toString().split("\\+");
				String str = "";
				for(String s : str_array) {
					if(str.length() > 0) {
						str += "," + s;
					}else {
						str += s;
					}
				}
				list.add(str);
			}
		}
		System.out.println(list);
		//list去重
		List<String> listWithoutDuplicates = list.stream().distinct().collect(Collectors.toList());
		System.out.println(listWithoutDuplicates);
	}

}